@extends('home.layout.base')
<link rel="stylesheet" href="{{URL::asset('./css/hrmy/address.css')}}">

@section('content')
<div class="mainHrContent" id="hrDownloadWord">
    <div class="storelistTitle">
        <span class="storelistTitle_left">
            <span>
                <img src="{{URL::asset('./img/icon/home.png')}}">
            </span>
            <span><a href="{{route('home.index.index') }}">首页</a> >
                <a href="{{route('home.hrmy.hrIndex') }}">用户中心</a>
                > 下载的文档
            </span>
        </span>
        <span class="storelistTitle_right">
            <span>找不到合适的供应商？发个需求试试？</span>
            <button @click=" window.location.href = '{{ route('home.demand.demandAdd') }}'">免费发布需求</button>
        </span>
    </div>
    <div class="hrContent">
        @include('home.hrmy.menu')
        <div class="basicInfo" id="hrDownloadWords">
            <div class="basicInfo_title">
                <span></span>
                下载的文档
            </div>
            <div class="tableAddr">
                <table>
                    <thead>
                        <tr>
                            <th >文档信息</th>
                            <th>下载时间</th>
                            <th>文档格式</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="item in listData"  @click="window.location.href = '{{ route('home.word.wordDetails') }}?id='+item.word_id">
                            <td style="max-width:400px;">@{{item.word_title}}</td>
                            <td>@{{item.created_at}}</td>
                            <td>
                                <img src="{{URL::asset('./img/icon/downWord.png')}}" v-if="item.word_format=='doc' || item.word_format=='docx'">
                                <img src="{{URL::asset('./img/icon/downPdf.png')}}" v-if="item.word_format=='pdf'">
                                <img src="{{URL::asset('./img/icon/downExel.png')}}" v-if="item.word_format=='xlsx' || item.word_format=='xls'">
                                <img src="{{URL::asset('./img/icon/downPPT.png')}}" v-if="item.word_format=='ppt'">

                            </td>
                            <td>
                                <span @click.stop="deleteCollect(item.id)">删除记录

                                </span>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="elementPage" style="margin-top: 20px;" v-if="pageCount>0">
                <el-pagination :pager-count="5" @current-change="handleCurrentChange" :current-page.sync="pageNumber" background prev-text="上一页" next-text="下一页" layout="prev, pager, next,jumper" :total="pageCount">
                </el-pagination>
            </div>
        </div>
    </div>
</div>
<style>
    tbody>tr:not(:last-child) {
        border-bottom: 1px solid rgba(204, 204, 204, 1);
    }

    .tableAddr tbody>tr img {
        width: 20px;
        height: 20px;
    }

    .tableAddr tbody>tr span {
        font-size: 12px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        line-height: 20px;
        color: rgba(51, 51, 51, 1);
        cursor: pointer;

    }

    .tableAddr tbody>tr span:hover {
        text-decoration: underline
    }
</style>
@endsection
@section('compontentScipts')
<script>
    $(() => {
        let hrDownloadWord = new Vue({
            el: '#hrDownloadWords',
            data: () => {
                return {
                    pageNumber: 1,
                    pageCount: 0,
                    listData: []
                }
            },
            created() {
                this.getList();
            },
            mounted() {},
            methods: {
                getList() {
                    let data = {}
                    apiAjax("{{ route('home.user.hrWordListApi')}}", 'get', data, (res) => {
                        if (res.code == 0) {
                            this.pageCount = res.data.total;
                            this.listData = res.data.data;
                        } else {
                            this.$message({
                                message: res.msg,
                                type: 'warning'
                            });
                        }
                    }, (erro) => {});
                },
                handleCurrentChange(val) {
                    this.pageNumber = val;
                    this.getList();
                },
                deleteCollect(id) {
                    let data = {
                        download_id:id
                    }
                    apiAjax("{{ route('home.user.hrWordCancelApi')}}", 'post', data, (res) => {
                        if (res.code == 0) {
                            this.$message({
                                message: res.msg,
                                type: 'success'
                            });
                            this.getList();
                        } else {
                            this.$message({
                                message: res.msg,
                                type: 'warning'
                            });
                        }
                    }, (erro) => {

                    });
                }
            }
        })
    })
</script>
@endsection